package control

import (
	"service/app/dao"
	"service/app/dto"
	"service/app/mode"
)

type MenusCont struct {
	BaseContr *BaseContr
	Dao       *dao.MenuDao
}

var menusCont *MenusCont

func MenuControlInit() *MenusCont {
	if menusCont == nil {
		menusCont = &MenusCont{BaseContr: &BaseContr{}, Dao: dao.MenuDaoInit()}
	}
	return menusCont
}

func (m *MenusCont) MenusByIdsC(param *dto.ImenuList_updata) (*[]mode.Db_menu, error) {
	return m.Dao.MenusByIdsD(param)
}
func (m *MenusCont) MenuAddListC(param *dto.Imenulist_Add) error {
	return m.Dao.MenuAddListD(param)
}
func (m *MenusCont) MenuAdd(param *dto.ImenusAdd) error {
	return m.Dao.MenuAdd(param)
}

// func (m *MenusCont) MenusSqlExits(api string) {
// 	return m.Dao.MenusSqlExitsD(api)
// }

func (m *MenusCont) MenuGetAll() (*[]mode.Db_menu, error) {
	return m.Dao.MenuAll()
}

func (m *MenusCont) MenuDel(id *dto.ReqIdDto) error {
	return m.Dao.MenuDel(id)
}

func (m *MenusCont) MenuEditC(id int, param *dto.ImenusAdd) error {
	return m.Dao.MenuEiteD(id, param)
}

func (m *MenusCont) MenuPath() (*[]mode.Db_menu, error) {
	exitlist, err := m.Dao.MenuAll()
	if err != nil {
		return nil, err
	}
	return exitlist, nil
}
